//路由配置信息   用路由懒加载
//import Home from '@/pages/Home'
//import Search from '@/pages/Search/'
//import Login from '@/pages/Login'
//import Register from '@/pages/Register'
//import Detail from '@/pages/Detail'
//import AddCartSuccess from '@/pages/AddCartSuccess'
//import ShopCart from '@/pages/ShopCart'
//import Trade from '@/pages/Trade'
//import Pay from '@/pages/Pay'
//import PaySuccess from '@/pages/PaySuccess'
//import Center from '@/pages/Center'
//引入二级路由组件
//import MyOrder from '@/pages/Center/myOrder'
//import GroupOrder from '@/pages/Center/grouoOrder'
export default [
    {
        path: "/center",
        component: ()=>import('@/pages/Center'),
        children: [
            {
                path: 'myorder',
                component:()=>import('@/pages/Center/myOrder'),
            },
            {
                path: 'grouporder',
                component:()=>import('@/pages/Center/grouoOrder'),
            },
            {
                path: '/center',
                redirect:'/center/myorder'
            }

            
        ]
    },
    {
        path: "/paysuccess",
        component: ()=>import('@/pages/PaySuccess'),
        meta: {show:true}
    },
    {
        path: "/pay",
        component: ()=>import('@/pages/Pay'),
        meta: { show: true },
        beforeEnter: (to, from, next)=>{ 
            if (from.path == '/trade') {
                next()
            } else { 
                next(false)
            }
        }
    },
    {
        path: "/trade",
        component: ()=>import('@/pages/Trade'),
        meta: { show: true },
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            //去交易页 只能从购物车页面去
            if (from.path == '/shopcart') {
                next()
            } else { 
                next(false)  //中断当前导航 改变url 时那么url会重置到from的地址
            }
        }
    },
    {
        path: "/shopcart",
        component: ()=>import('@/pages/ShopCart'),
        meta: {show:true}
    },

    {
        path: "/addcartsuccess",
        name:'addcartsuccess',
        component: ()=>import('@/pages/AddCartSuccess'),
        meta: {show:true}
    },
    {
        path: "/detail/:skuid",
        component: ()=>import('@/pages/Detail'),
        meta: {show:true}
    },
    {
        path: "/home",
        //路由懒加载  用户访问的时候才跳到这个页面
        component: ()=>import('@/pages/Home'),
        meta: {show:true}
    },
    {
        path: "/search/:keyword?",
        component: ()=>import('@/pages/Search'),
        meta: { show: true },
        name: "search",
        //路由组件能不能传递props参数？可以 有3种写法
        //布尔值写法params  
       // props:true,  //可以把params参数作为路由组件的属性  只能传递params参数
       //对象写法 额外给路由组件传递props
      //  props: {a:1,b:2},
      //函数写法 可以把params参数和query参数通过props传递给路由组件
        props: ($route) => ( {keyword:$route.params.keyword,k:$route.query.k})
    },
    {
        path: "/login",
        component: ()=>import('@/pages/Login'),
        meta: { show: false },
        
    },
    {
        path: "/register",
        component: ()=>import('@/pages/Register'),
        meta: {show:false}
    },
    //重定向，在项目跑起来的时候，访问/时立马定向到首页
    {
        path: '*',
        redirect:"/home"
    }
]